#include <math.h>
#include <stdio.h>
typedef struct {
    double real; // 实部
    double imag; // 虚部
} Complex;

int calculateComplex(Complex c1, Complex c2, int type, Complex *result, double *mod) {
    if (type == 3 && c2.real == 0 && c2.imag == 0)
        return 0;
    else {
        if (type == 0) {
            result->real = c1.real + c2.real;
            result->imag = c1.imag + c2.imag;
        }
        if (type == 1) {
            result->real = c1.real - c2.real;
            result->imag = c1.imag - c2.imag;
        }
        double a = c1.real, b = c1.imag, c = c2.real, d = c2.imag;
        if (type == 2) {
            result->real = a * c - b * d;
            result->imag = a * d + b * c;
        }
        if (type == 3) {
            result->real = (a * c + b * d) / (c * c + d * d);
            result->imag = (-a * d + b * c) / (c * c + d * d);
        }
        if (type == 4) {
            // printf("%lf %;")
            *mod = sqrt(a * a + b * b);
        }
    }
    return 1;
}

int main() {
    Complex c1, c2, result;
    int type;
    double mod;
    scanf("%d", &type);
    scanf("%lf %lf", &c1.real, &c1.imag);
    if (type != 4) { // 如果不是求模运算，需要读入第二个复数
        scanf("%lf %lf", &c2.real, &c2.imag);
    }

    if (calculateComplex(c1, c2, type, &result, &mod)) {
        if (type == 4) {
            printf("%.2f\n", mod);
        } else {
            printf("%.2f + %.2fi\n", result.real, result.imag);
        }
    } else {
        printf("计算失败\n");
    }

    return 0;
}